package com.atguigu.democustomer230315.mapper;

import com.atguigu.democustomer230315.bean.Customer;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
@DS("test")
public interface  CustomerMapper extends BaseMapper<Customer> {

    @Select("select * from customer where name=#{name}")
    public Customer selectCustomerByName(@Param("name") String name);
    @Select("${sql}")
    public Customer selectCustomerByNameNoSQl(@Param("sql") String sql);

    @Insert("INSERT INTO customer(name,age) VALUES(#{name},${age})")
    public void insertCustomerByNameAndAge(@Param("name") String name, @Param("age") Integer age);

    @Insert("INSERT INTO customer(name,age) VALUES(#{customer.name},#{customer.age})")
    @DS("demo")
    public void insertCustomerByObj(@Param("customer") Customer customer);


}
